package com.sip.dbadapter.dao.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 */
@Entity
@Table(name = "RELEASE_VERSION")
public class ReleaseVersion implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long releaseId;

    private String version;

    private String name;

	private String url;

    private Date dataCreated;

    private Set<ApiDefinition> apiDefinitionSet;

    public ReleaseVersion() {

    }

    @Id
    @Column(name = "RELEASE_ID", unique = true, nullable = false)
    @GeneratedValue
    public Long getReleaseId() {

        return releaseId;
    }

    @Column(name = "VERSION", nullable = true)
    public String getVersion() {

        return version;
    }

    @Column(name = "NAME", nullable = true)
    public String getName() {

        return name;
    }
    
    @Column(name = "APPLICATION_URL", nullable = true)
	public String getUrl() {
		return url;
	}

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "DATE_CREATED")
    public Date getDataCreated() {

        return dataCreated;
    }

    @OneToMany(mappedBy = "releaseVersion")
    public Set<ApiDefinition> getApiDefinitionSet() {

        return apiDefinitionSet;
    }

    public void setReleaseId(Long releaseId) {

        this.releaseId = releaseId;
    }

    public void setVersion(String version) {

        this.version = version;
    }

    public void setName(String name) {

        this.name = name;
    }

    public void setDataCreated(Date dataCreated) {

        this.dataCreated = dataCreated;
    }
    

	public void setUrl(final String url) {
		this.url = url;
	}
    

    public void setApiDefinitionSet(Set<ApiDefinition> apiDefinitionSet) {

        this.apiDefinitionSet = apiDefinitionSet;
    }

    @Override
    public int hashCode() {

        int result = 0;
        result = (int) (31 * result + releaseId);
        result = 31 * result + (version != null ? version.hashCode() : 0);

        return result;
    }

    @Override
    public boolean equals(Object other) {

        if (this == other)
            return true;

        if (other == null || (this.getClass() != other.getClass())) {
            return false;
        }

        ReleaseVersion record = (ReleaseVersion) other;
        return (this.releaseId == record.releaseId) && (this.version != null && version.equals(record.version));

    }

}
